From: kfraser@localhost.localdomain Date: Thu, 6 Sep 2007 17:04:42 +0000 (+0100) Subject: [XSM] correctly located update_va_mapping hook within x86 ifdefs X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~14987^2~12 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=3b2aadebed757d37c4f004a3bc23aa435d922fa5;p=xen.git [XSM] correctly located update_va_mapping hook within x86 ifdefs The following patch addresses the issue where the XSM update_va_mapping hook was not correctly located inside the x86 ifdefs. Included are updates for the dummy and flask modules which are also effected by this issue. - update_va_mapping ifdef fix for xsm - update_va_mapping ifdef fix for dummy module - update_va_mapping ifdef fix for flask module Signed-off-by: George Coker --- diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h index 3a6cbde29e..6debf6070c 100644 --- a/xen/include/xsm/xsm.h +++ b/xen/include/xsm/xsm.h @@ -99,7 +99,6 @@ struct xsm_operations { int (*memory_adjust_reservation) (struct domain *d1, struct domain *d2); int (*memory_stat_reservation) (struct domain *d1, struct domain *d2); int (*memory_pin_page) (struct domain *d, struct page_info *page); - int (*update_va_mapping) (struct domain *d, l1_pgentry_t pte); int (*console_io) (struct domain *d, int cmd); @@ -135,6 +134,7 @@ struct xsm_operations { int (*domain_memory_map) (struct domain *d); int (*mmu_normal_update) (struct domain *d, intpte_t fpte); int (*mmu_machphys_update) (struct domain *d, unsigned long mfn); + int (*update_va_mapping) (struct domain *d, l1_pgentry_t pte); int (*add_to_physmap) (struct domain *d1, struct domain *d2); #endif }; @@ -366,11 +366,6 @@ static inline int xsm_memory_pin_page(struct domain *d, struct page_info *page) return xsm_call(memory_pin_page(d, page)); } -static inline int xsm_update_va_mapping(struct domain *d, l1_pgentry_t pte) -{ - return xsm_call(update_va_mapping(d, pte)); -} - static inline int xsm_console_io (struct domain *d, int cmd) { return xsm_call(console_io(d, cmd)); @@ -528,6 +523,11 @@ static inline int xsm_mmu_machphys_update (struct domain *d, unsigned long mfn) return xsm_call(mmu_machphys_update(d, mfn)); } +static inline int xsm_update_va_mapping(struct domain *d, l1_pgentry_t pte) +{ + return xsm_call(update_va_mapping(d, pte)); +} + static inline int xsm_add_to_physmap(struct domain *d1, struct domain *d2) { return xsm_call(add_to_physmap(d1, d2)); diff --git a/xen/xsm/dummy.c b/xen/xsm/dummy.c index c572f67799..8379b69c50 100644 --- a/xen/xsm/dummy.c +++ b/xen/xsm/dummy.c @@ -187,11 +187,6 @@ static int dummy_memory_stat_reservation (struct domain *d1, struct domain *d2) return 0; } -static int dummy_update_va_mapping (struct domain *d, l1_pgentry_t pte) -{ - return 0; -} - static int dummy_console_io (struct domain *d, int cmd) { return 0; @@ -381,6 +376,11 @@ static int dummy_mmu_machphys_update (struct domain *d, unsigned long mfn) return 0; } +static int dummy_update_va_mapping (struct domain *d, l1_pgentry_t pte) +{ + return 0; +} + static int dummy_add_to_physmap (struct domain *d1, struct domain *d2) { return 0; @@ -448,7 +448,6 @@ void xsm_fixup_ops (struct xsm_operations *ops) set_to_dummy_if_null(ops, memory_adjust_reservation); set_to_dummy_if_null(ops, memory_stat_reservation); set_to_dummy_if_null(ops, memory_pin_page); - set_to_dummy_if_null(ops, update_va_mapping); set_to_dummy_if_null(ops, console_io); @@ -483,6 +482,7 @@ void xsm_fixup_ops (struct xsm_operations *ops) set_to_dummy_if_null(ops, domain_memory_map); set_to_dummy_if_null(ops, mmu_normal_update); set_to_dummy_if_null(ops, mmu_machphys_update); + set_to_dummy_if_null(ops, update_va_mapping); set_to_dummy_if_null(ops, add_to_physmap); #endif } diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c index 740d7b8474..6ed15d8cea 100644 --- a/xen/xsm/flask/hooks.c +++ b/xen/xsm/flask/hooks.c @@ -407,27 +407,6 @@ static DEFINE_PER_CPU(struct percpu_mm_info, percpu_mm_info); */ #define FOREIGNDOM (this_cpu(percpu_mm_info).foreign ?: current->domain) -static int flask_update_va_mapping(struct domain *d, l1_pgentry_t pte) -{ - int rc = 0; - u32 psid; - u32 map_perms = MMU__MAP_READ; - unsigned long mfn; - struct domain_security_struct *dsec; - - dsec = d->ssid; - - mfn = gmfn_to_mfn(FOREIGNDOM, l1e_get_pfn(pte)); - rc = get_mfn_sid(mfn, &psid); - if ( rc ) - return rc; - - if ( l1e_get_flags(pte) & _PAGE_RW ) - map_perms |= MMU__MAP_WRITE; - - return avc_has_perm(dsec->sid, psid, SECCLASS_MMU, map_perms, NULL); -} - static int flask_console_io(struct domain *d, int cmd) { u32 perm; @@ -1036,6 +1015,27 @@ static int flask_mmu_machphys_update(struct domain *d, unsigned long mfn) return avc_has_perm(dsec->sid, psid, SECCLASS_MMU, MMU__UPDATEMP, NULL); } +static int flask_update_va_mapping(struct domain *d, l1_pgentry_t pte) +{ + int rc = 0; + u32 psid; + u32 map_perms = MMU__MAP_READ; + unsigned long mfn; + struct domain_security_struct *dsec; + + dsec = d->ssid; + + mfn = gmfn_to_mfn(FOREIGNDOM, l1e_get_pfn(pte)); + rc = get_mfn_sid(mfn, &psid); + if ( rc ) + return rc; + + if ( l1e_get_flags(pte) & _PAGE_RW ) + map_perms |= MMU__MAP_WRITE; + + return avc_has_perm(dsec->sid, psid, SECCLASS_MMU, map_perms, NULL); +} + static int flask_add_to_physmap(struct domain *d1, struct domain *d2) { return domain_has_perm(d1, d2, SECCLASS_MMU, MMU__PHYSMAP); @@ -1090,7 +1090,6 @@ static struct xsm_operations flask_ops = { .memory_adjust_reservation = flask_memory_adjust_reservation, .memory_stat_reservation = flask_memory_stat_reservation, .memory_pin_page = flask_memory_pin_page, - .update_va_mapping = flask_update_va_mapping, .console_io = flask_console_io, @@ -1125,6 +1124,7 @@ static struct xsm_operations flask_ops = { .domain_memory_map = flask_domain_memory_map, .mmu_normal_update = flask_mmu_normal_update, .mmu_machphys_update = flask_mmu_machphys_update, + .update_va_mapping = flask_update_va_mapping, .add_to_physmap = flask_add_to_physmap, #endif };